package fr.istic.mmm.coursepoursuite.simulateur;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import android.content.Context;

import com.google.gson.Gson;

import fr.istic.mmm.coursepoursuite.parcours.Point;
import fr.istic.mmm.coursepoursuite.parcours.Points;

public class Simulateur {
	private Points lesPoints;
	private int nb = 0;

	public Simulateur(Context context){
		// lecture du fichier Json qui contient les coordonnées
		// et remplissage de la liste
		lesPoints = new Points();
		Gson gson = new Gson();

		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(context.getAssets().open("googleMap/points.json")));
			lesPoints = gson.fromJson(reader, Points.class);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public Point getNextPoint(){

		if(nb >= 0 && nb < lesPoints.getLesPoints().size()){
			Point point = lesPoints.getLesPoints().get(nb);
			nb++;
			return point;
		}
		else {
			return null;
		}

	}
	
	public Points getLesPoints() {
		return lesPoints;
	}

	public void setLesPoints(Points lesPoints) {
		this.lesPoints = lesPoints;
	}


}
